<div class="layui-row layui-col-space15" id="recharge">
    <div class="layui-col-md12">
        <div class="layui-card hxr-layui-card">
             <div class="layui-form hxradmin-card-header">
                <div class="layui-form-item">
                    <div class="layui-inline">
                        <label class="layui-form-label">类型</label>
                        <div class="layui-input-inline">
                            <div class="layui-unselect layui-form-select">
                                <div class="layui-select-title"><input name="type" type="text" value="" readonly class="layui-input layui-unselect"><i
                                        class="layui-edge"></i></div>
                                <dl class="layui-anim layui-anim-upbit" style="">
                                    <dd lay-value="" class="layui-select-tips layui-this">选择状态</dd>
                                    <dd data='1'>分配</dd>
                                    <dd data='2'>回收</dd>
                                </dl>
                            </div>
                        </div>
                    </div>
                    <div class="layui-inline">
                        <button class="layui-btn" data-type="reload" id="searchs">搜索</button>
                    </div>
                </div>
            </div>
            <div class="layui-card-body">
                <table class="layui-hide" id="list-select-table" lay-filter="list-select-table"></table>
                <script type="text/html" id="status">
                    {{#  if(d.type === 1){ }}
                    <span class="layui-badge layui-bg-green">分配</span>
                    {{#  } else if(d.type === 2) { }}
                    <span class="layui-badge">回收</span>
                    {{#  } }}
                </script>
            </div>
        </div>
    </div>
</div>
<script>
    //表格数据渲染
    layui.use(['table', 'form'], function() {
        var table = layui.table,
            form = layui.form,
            $ = layui.$;

        layui.admin.initlist(table,'device/distribution_list',350,[
            [ {
                field: 'agent_name',
                title: '代理名称',
                width: 300
            }, {
                field: 'type',
                title: '类型',
                minWidth: 150,
                templet:'#status'
            },{
                field: 'create_time',
                title: '创建时间',
                width: 250
            }]
        ],'#list-select-table',500,'',{device_id:layui.admin.objData.detail.device_id});
        // $('#searchs').on('click', function() {
        //     var type = $('input[name="type"]').val();
        //     layui.admin.reloads({
        //         device_id:layui.admin.objData.detail.device_id,
        //         type:type,
        //     });
        // });
        $('#searchs').on('click', function() {
            var type = $('input[name="type"]').attr('data');
        	//执行重载
        	table.reload('list-select-table', {
        		page: {
        			curr: 1 //重新从第 1 页开始
        		},
        		where: {
                    device_id:layui.admin.objData.detail.device_id,
                    type:type,
        		}
        	});
        });
    });
</script>
